<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>多彩主题背景切换</title>
<style>
    body {
        background: url(bg_images/d1.png) no-repeat center/cover;
    }
    .wrapper {
        display: flex;
        justify-content: space-evenly;
        align-items: center;
        margin: 100px auto;
        width: 780px;
        padding: 15px;
        background: rgba(50,50,50,0.6);
        border-radius: 15px;
    }
    img {
        width: 150px;
        height: 200px;
        border-radius: 5px;
        cursor: pointer;
        transition: transform 0.3s, filter 0.3s;
    }
    img:hover {
        transform: scale(1.12);
        filter: brightness(1.2);
    }
    .tip {
        text-align: center;
        color: #fff;
        margin-top: 20px;
        font-size: 18px;
        font-family: "Microsoft YaHei";
    }
</style>
</head>
<body>
    <div class="wrapper">
        <img src="bg_images/d1.png" alt="">
        <img src="bg_images/d2.jpg" alt="">
        <img src="bg_images/d3.jpg" alt="">
        <img src="bg_images/d4.jpg" alt="">
    </div>
    <div class="tip">点击上方图片可切换背景</div>
<script>
    var imgs = document.querySelectorAll('.wrapper img');
    for (let i=0;i<imgs.length;i++){
        imgs[i].addEventListener("click", function(){
            document.body.style.backgroundImage = `url(${this.src})`;
        });
    }
</script>
</body>
</html>
